# ~*~ coding: utf-8 ~*~
import time

from apps.common.dbbase import BaseModel
from apps.common.utils import generate_uuid
from apps.extensions import db

__all__ = ['Filter']


class Filter(BaseModel):
    # 表的名字:
    __tablename__ = 'codes_filter'

    id = db.Column(db.CHAR(36), default=generate_uuid, primary_key=True)
    # 所属的项目
    project_id = db.Column(db.CHAR(36), nullable=True)
    # 文件路径
    filename = db.Column(db.VARCHAR(64), nullable=True)
    # 文件内容
    content = db.Column(db.TEXT, nullable=True, default='')

    create_by = db.Column(db.VARCHAR(32), nullable=True)
    create_time = db.Column(db.INT, default=time.time)
    update_time = db.Column(db.INT, default=time.time, onupdate=time.time)

    def __str__(self):
        return '<Filter: {}>'.format(self.filename)
